// outer shell for the actual stop alert input filter
{
Boolean boolRetVal;
boolRetVal = DoCustomModalAlertFilter(pdlgAlert,pevntAlert,psHit,STOP_ALERT); // call the actual modal filter as a separate function, to avoid optimizing compilers from messing up the SetCurrentA4 operation
return boolRetVal; // signal if processing is complete
// outer shell for the actual caution alert input filter
{
Boolean boolRetVal;
boolRetVal = DoCustomModalAlertFilter(pdlgAlert,pevntAlert,psHit,CAUTION_ALERT); // call the actual modal filter as a separate function, to avoid optimizing compilers from messing up the SetCurrentA4 operation
return boolRetVal; // signal if processing is complete
// outer shell for the actual note alert input filter
{
Boolean boolRetVal;
boolRetVal = DoCustomModalAlertFilter(pdlgAlert,pevntAlert,psHit,NOTE_ALERT); // call the actual modal filter as a separate function, to avoid optimizing compilers from messing up the SetCurrentA4 operation
return boolRetVal; // signal if processing is complete
} // CustomModalNoteAlertFilter()
int ReportError(Str255 strError1,Str255 strError2)
// put up an error dialog
{
ModalFilterUPP umfAlert;
SetCursor(&qd.arrow); // replace MPW beach ball cursor with arrow
(void) signal(SIGINT,SIG_IGN); // disable command-period abort when alert is displayed
umfAlert = NewModalFilterProc(CustomModalStopAlertFilter); // get a routine descriptor (or UniversalProcPtr for 68k) for the stop alert dialog filter function
ParamText("\pPairs",strError1,strError2,"\p");
(void) StopAlert(ALERT_ID,umfAlert);
DisposeRoutineDescriptor((UniversalProcPtr) umfAlert); // dispose of the routine descriptor
SetCursor(&qd.arrow); // replace MPW beach ball cursor with arrow
(void) signal(SIGINT,SIG_IGN); // disable command-period abort when alert is displayed
umfAlert = NewModalFilterProc(CustomModalCautionAlertFilter); // get a routine descriptor (or UniversalProcPtr for 68k) for the caution alert dialog filter function
ParamText("\pPairs",strMismatch,"\p","\p");
(void) CautionAlert(ALERT_ID,umfAlert);
DisposeRoutineDescriptor((UniversalProcPtr) umfAlert); // dispose of the routine descriptor
SetCursor(&qd.arrow); // replace MPW beach ball cursor with arrow
(void) signal(SIGINT,SIG_IGN); // disable command-period abort when alert is displayed
umfAlert = NewModalFilterProc(CustomModalNoteAlertFilter); // get a routine descriptor (or UniversalProcPtr for 68k) for the note alert dialog filter function
ParamText("\pPairs",strNoMismatch,"\p","\p");
(void) NoteAlert(ALERT_ID,umfAlert);
DisposeRoutineDescriptor((UniversalProcPtr) umfAlert); // dispose of the routine descriptor
boolRetVal = DoCustomModalDialogFilter(pdlgGeneric,pevntGeneric,psHit); // call the actual modal filter as a separate function, to avoid optimizing compilers from messing up the SetCurrentA4 operation
return boolRetVal; // signal if processing is complete
} // CustomModalDialogFilter()
Boolean PairsDialog(int *piMode)
// Pairs edit dialog box routine
{
Boolean boolRetVal;
short sDummy,sIndex,sHit,sTemp;
DialogPtr pdlogPairs;
Rect rectTemp;
Handle hdlogItem;
ControlHandle hctrlItem,hctrlTemp;
ModalFilterUPP umfDialog;
(void) signal(SIGINT,SIG_IGN); // disable command-period abort when dialog is displayed
pdlogPairs = GetNewDialog(DITL_ID,NULL,(WindowPtr) -1); // bring in the dialog resource
if (pdlogPairs != NULL)
{
SetPort(pdlogPairs); // ensure the correct port is current
(void) SetDialogDefaultItem(pdlogPairs,ok); // ensure that the default button is defined
(void) SetDialogCancelItem(pdlogPairs,cancel); // ensure that the cancel button is defined
umfDialog = NewModalFilterProc(CustomModalDialogFilter); // get a routine descriptor (or UniversalProcPtr for 68k) for the custom dialog filter function
// set up radio buttons to a default value
for (sIndex = CURLY_BRACE_RADIO; sIndex <= COMMENT_RADIO; sIndex++)
{
// clear all radios
GetDialogItem(pdlogPairs,sIndex,&sDummy,&hdlogItem,&rectTemp); // get the item handle
hctrlTemp = (ControlHandle) hdlogItem; // get the control handle
SetControlValue(hctrlTemp,0); // turn the radio selection off
} // for sIndex
GetDialogItem(pdlogPairs,CURLY_BRACE_RADIO,&sDummy,&hdlogItem,&rectTemp); // get the item handle
hctrlItem = (ControlHandle) hdlogItem; // get the control handle
SetControlValue(hctrlItem,1); // select the radio
ShowWindow(pdlogPairs); // open a dialog box
SelectWindow(pdlogPairs); // make it visible
do
{
ModalDialog(umfDialog,&sHit); // wait until an item is hit
GetDialogItem(pdlogPairs,sHit,&sDummy,&hdlogItem,&rectTemp); // get item information
hctrlItem = (ControlHandle) hdlogItem; // get the control handle
switch (sHit)
{
case CURLY_BRACE_RADIO :
case SQUARE_BRACE_RADIO :
case PARENTHESIS_RADIO :
case DBL_QUOTE_RADIO :
case SNGL_QUOTE_RADIO :
case COMMENT_RADIO :
{
for (sIndex = CURLY_BRACE_RADIO; sIndex <= COMMENT_RADIO; sIndex++)
{
// clear all radios
GetDialogItem(pdlogPairs,sIndex,&sDummy,&hdlogItem,&rectTemp); // get the item handle
hctrlTemp = (ControlHandle) hdlogItem; // get the control handle
SetControlValue(hctrlTemp,0); // turn the radio selection off
} // for sIndex
SetControlValue(hctrlItem,1); // turn the one radio selection on
break;
} // case CURLY_BRACE_RADIO … COMMENT_RADIO
} // switch sHit
} // do
while ((sHit != OK_BUTTON) && (sHit != CANCEL_BUTTON));
// Get results after dialog
if (sHit == CANCEL_BUTTON)
{
boolRetVal = true;
} // if sHit
else
{
boolRetVal = false;
} // else if sHit
if (!boolRetVal)
{
sIndex = CURLY_BRACE_RADIO; // start at the first radio in this group
do
{
GetDialogItem(pdlogPairs,sIndex,&sDummy,&hdlogItem,&rectTemp); // get the item handle
hctrlItem = (ControlHandle) hdlogItem; // get the control handle
sTemp = GetControlValue(hctrlItem); // get the radio value
sIndex++;
} // do
while ((sTemp != 1) && (sIndex <= COMMENT_RADIO));
*piMode = sIndex - CURLY_BRACE_RADIO - 1;
boolRetVal = false;
} // if !boolRetVal
DisposeDialog(pdlogPairs); // flush the dialog out of memory
DisposeRoutineDescriptor((UniversalProcPtr) umfDialog); // dispose of the routine descriptor
} // if pdlogPairs
else
{
ReportError("\pUnable to continue:","\pCan't create the dialog box.");